/*
 *  $Id: VolcanicDragon.cs 1221 2010-11-30 16:54:52Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Fire.Creatures {
    public class VolcanicDragon: CreatureCard<ChainData> {
        public VolcanicDragon(): base("001_f_c_volcanic_dragon") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Fire;
            Value = 100;
            Target = new ChainTarget(null,
                new LandTarget(GetTargetPhrase(), true, false, IsVolcano),
                SummonTarget.Summon);
            SetRace<Races.Dragon>();
            Damage = 9;
            Health = 7;
            AddManaCost(ElementType.Fire, 10);
        }
        public override void SetNaturalAffects(ICollector<Affect> affects) {
            affects.Add<Affects.Flight>();
        }
        public override void SetAbilities(ICollector<AbilityCard> abilities) {
            abilities.Add<Abilities.DragonFireBreath>();
        }

        private static bool IsVolcano(TargetRequest request, Land land) { return land.Card is Lands.Volcano; }

        protected override void DoAction(TargetArgs<ChainData> args) {
            TargetArgs<Land> la;
            TargetArgs<int> sa;
            if (!args.Target.GetArgs(out la, out sa)) return;

            Abilities.Eruption.EruptionAffect affect = la.Target.GetAffect<Abilities.Eruption.EruptionAffect>();
            la.Target.Remove();
            Creature dragon = args.Player.SummonCreature(this, sa.Target);
            if (dragon != null && affect != null)
                dragon.AddAffect(new VolcanoAffect(affect.Value));
        }

        private class VolcanoAffect: SpellAffect<Lands.Volcano> {
            public int Value;

            public VolcanoAffect(int value): base(true) {
                DefaultDescription = true;
                Value = value;
                Add(new Affects.ModDamage(Value));
            }

            public override bool Dispellable {
                get { return false; }
            }

            public override string DescriptionText {
                get { return Description.GetText(Value); }
            }

            public override Affect Clone() {
                return new VolcanoAffect(Value);
            }
        }
    }
}
